package com.lsz.errorupload;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2016/11/11.
 */

public class DefaultExceptionHandler implements Thread.UncaughtExceptionHandler {

    private Context ctx;

    public DefaultExceptionHandler(Context ctx) {
        this.ctx = ctx;
    }

    @Override
    public void uncaughtException(Thread thread, final Throwable ex) {
        SharedPreferences sp = ctx.getSharedPreferences("errorLog",Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("errorTitle", ex.getCause().getClass().getName());
        editor.putString("errorMsg", ex.getMessage());
        editor.putString("errorType", "0");
        editor.putBoolean("isUpload",false);
        editor.commit();
        System.exit(0);
    }

}
